package admin

import "go-amis-admin/amis"

type EmptyModule struct {
	Label       string
	Name        string
	Icon        string
	Sort        uint
	BasePath    string
	PageSchema  amis.Obj
	Permissions PermList
}

func NewEmptyModule(label string, name string, icon string, sort uint, basePath string) EmptyModule {
	return EmptyModule{
		Label:       label,
		Name:        name,
		Icon:        icon,
		Sort:        sort,
		BasePath:    basePath + "/" + name,
		PageSchema:  amis.New("Page"),
		Permissions: []Permission{{"查看", name + ".view"}},
	}
}

func (m *EmptyModule) GetResource() Resource {
	return Resource{
		Label:     m.Label,
		Name:      m.Name,
		Icon:      m.Icon,
		Url:       "/" + m.Name,
		SchemaApi: "get:" + m.GetApiUrl("indexView"),
		PermList:  m.Permissions,
	}
}

func (m *EmptyModule) GetApiUrl(path string) string {
	return m.BasePath + "/" + path
}

func (m *EmptyModule) GetRouterPath(path string) string {
	return "/" + m.Name + "/" + path
}
